<style type="text/css">
.ui-progressbar {
    height: 0.6em;
    text-align: left;
	width:99%;
}
.ui-widget-header {
    background: #3dba0c;
    border: 1px solid #2b9700;
    color: #fff;
    font-weight: bold;
}
</style>
<div class="tnm-col">
	<h2 class="title-tnm-col">Quản lý sân</h2>
    <div class="content-tnm-col">
    	<div class="bigyard">
            <?php foreach ($stadiums7 as $stadium) : ?>
            <a href="<?php echo $this->createUrl('/wdcalendar/default',array('stadium_id'=>$stadium->name)); ?>" title="" class="choose">
            	<div class="timeline" title="<?php echo $stadium->name ?>" id="stadium_status_<?php echo $stadium->name ?>"></div>
                <div class="player7">
                	<div class="number7"><?php echo $stadium->name; ?></div>
                    <?php 
                    $stadiumstable = StadiumsTables::model()->findByAttributes(array('stadium_id'=>$stadium->id));
                    if ($stadiumstable) : ?>
                    <div class="table-name7"><?php echo Yii::app()->numberFormatter->format('00', $stadiumstable->table_name); ?></div>
                    <?php endif; ?>
                </div>
           	</a>
           	<?php endforeach; ?>
        </div>
        <div class="smallyard">
            <?php foreach ($stadiums5 as $stadium) : ?>
        	<a href="<?php echo $this->createUrl('/wdcalendar/default',array('stadium_id'=>$stadium->name)); ?>" title="" class="choose">
            	<div class="timeline" title="<?php echo $stadium->name ?>" id="stadium_status_<?php echo $stadium->name ?>"></div>
                <div class="player5">
                	<div class="number5"><?php echo $stadium->name; ?></div>
                    <?php 
                    $stadiumstable = StadiumsTables::model()->findByAttributes(array('stadium_id'=>$stadium->id));
                    if ($stadiumstable) : ?>
                    <div class="table-name5"><?php echo Yii::app()->numberFormatter->format('00', $stadiumstable->table_name); ?></div>
                    <?php endif; ?>
                </div>
            </a>
            <?php endforeach; ?>
            
        </div>
        <a href="<?php echo $this->createUrl('/wdcalendar') ?>" title="" class="bt-getyard btn-order-play"><img src="images/btn-order.png" width="142" height="44" /></a>
        <a href="<?php echo $this->createUrl('/canteen') ?>" title="" class="bt-getyard1 btn-add-fashion"><img src="images/btn-uniform.png" width="142" height="44" /></a>         	
    </div>
    <div class="bottom-tnm-col"></div>
</div>
<div class="tnm-col right">
    <h2 class="title-tnm-col">QUản lý Căng tin</h2>
    <div class="content-tnm-col">
    	<div id="photo_gallery">
        <div id="photoContainer">
          <div id="arr_left"><img alt="" style="cursor: pointer;" onclick="HscrollER('photoImages','photoContainer','1','568','left','19');" src="images/btn_left.png"></div>
          <div id="arr_right"><img alt="" style="cursor: pointer;" onclick="HscrollER('photoImages','photoContainer','1','568','right','19');" src="images/btn_right.png"></div>
          <div id="photoImages">
            <ul>
            <?php for ($i=1; $i<=$tables; $i++) : ?>
            <?php $checkout = OrdersTables::model()->checkoutByTable($i);  ?>
              <a class="none" rel="<?php echo $checkout['total_money']; ?>" id="canteen_table_<?php echo $i; ?>" href="<?php echo $this->createUrl('/canteen/index',array('table_id'=>$i)); ?>">
              	<li>
                	<span class="text"><?php echo Yii::app()->numberFormatter->format('00', $i); ?></span>
                    <span class="money"><?php $checkout = OrdersTables::model()->checkoutByTable($i); echo Yii::app()->numberFormatter->format('###,###', $checkout['total_money']); ?> vnd</span>
                </li>
              </a>
              <?php if ($i%12==0) echo '</ul><ul>'; ?>
            <?php endfor; ?>		  
            </ul>
          </div>
        </div>
      </div>
    </div>
    <div class="bottom-tnm-col"></div>
</div>

<!-- ----------------Lock Screen---------------------- -->
<div id="dialog-form" class="dialog-lock" title="ĐĂNG NHẬP">
	<div class="dialog-new">
        <form action="" method="get">
            <div class="style-form">
                
                <dl>
                    <dt>Tên đăng nhập:</dt>
                    <dd><input type="text"/></dd>                     
                </dl>
                <dl>
                    <dt>Mật khẩu :</dt>
                    <dd><input type="password" style="height:23px; width:206px; padding:0 0 0 4px"/></dd>                     
                </dl>
                <dl>
                    <dt></dt>
                    <dd>
                        <div class="button"><a href="#">Đăng nhập</a></div>
                    </dd>                  
                </dl>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">

function checkStatusStadium()
{
    $('.timeline').each(function(){
       var id = $(this).attr('title');
       
       var url = '<?php echo $this->createUrl('/stadiums/check') ?>';
       $.post(url,{stadium : id},function(resp){    
        console.log(resp);
                $('#stadium_status_' + id).progressbar( {value : resp.value});
       },"json"); 
    });
}

$().ready(function(){
    checkStatusStadium();
    // check progressbar each 1 min
    setInterval("checkStatusStadium()",60000);
    
    $(".timeline").progressbar(); 
    
    $('.btn-order-play,.btn-add-fashion').click(function(){
       window.location.href = $(this).attr('href');
      ;      
    })
    
    $('#dialog-form .dialog-new input').keypress(function(e){
       if(e.which == 13)
       {
         $('#dialog-form .button').click();
       } 
    });
	
    $('#dialog-form .button').click(function(){
        var usr = $('#dialog-form input[type="text"]').val();
        var pwd = $('#dialog-form input[type="password"]').val();
        if(usr == '')
        {
            alert('Chưa nhập tên đăng nhập');
            return false;
        }
        
        if(pwd == '')
        {
            alert('Chưa nhập mật khẩu');
            return false;
        }
        
        var url = '<?php echo $this->createUrl('/user/login/check') ?>';
        $.post(url,{ user : usr , password : pwd },function(resp){            
            if(resp == '0')
            {
                alert('Đăng nhập thất bại');
            }
            else
            {
				$('#dialog-form input[type="text"]').val('');
				$('#dialog-form input[type="password"]').val('');
                $("#dialog-form").dialog("close");
            }
        });
        
    });
});
</script>
<style type="text/css">
.ui-dialog-titlebar-close{
    display: none;
}
</style>